/////precompiled////////
#include "precompiled.h"
////////////////////////


#include "prs_GrfLines.h"
using namespace prs;

// TRulergb //////////////////////////////////////////////////////////////
//
TRulergbw::TRulergbw( snt::text::TContext &Context
				    , svl::TVariant &VR
				    , svl::TVariant &VG
				    , svl::TVariant &VB
					, svl::TVariant &VW )
: vR(VR), vG(VG), vB(VB), vW(VW)
{
  snt::TReturn         Return;
  snt::text::TSequence T(Context);
  snt::text::TNumber   N(Context);

  (*this)
  | N.New(vR) & T.New(",") 
  & N.New(vG) & T.New(",") 
  & N.New(vB) & T.New(",")
  & N.New(vW) & Return.New()
  ;
}

// TRuleGrfLine ///////////////////////////////////////////////////////
//
TRuleGrfLine::TRuleGrfLine( snt::text::TContext &Context, svl::TVariant &VColor, svl::TVariant &VWeight)
: vColor(VColor)
, vWeight(VWeight)
, Rrgbw(Context,vR,vG,vB,vW)
, vThis(this) {}

//
void TRuleGrfLine::FColor(snt::TParams &Params){
	TRuleGrfLine *This = dynamic_cast<TRuleGrfLine*>( Params.Pop().Pointer() );
	grf::TColor *color = dynamic_cast<grf::TColor*>(This->vColor.Pointer());
	//int *weight        = dynamic_cast<int*>(This->vWeight.Pointer());
	color->R = This->vR.Integer();
	color->G = This->vG.Integer();
	color->B = This->vB.Integer();
	This->vWeight= This->vW.Integer();
}

// TRuleGrfLineHT //////////////////////////////////////////////////////////////
//
TRuleGrfLineHT::TRuleGrfLineHT( snt::text::TContext &Context, svl::TVariant &VColor, svl::TVariant &VWeight)
: TRuleGrfLine(Context,VColor,VWeight)
{ 
  snt::TReturn         Return;
  snt::TFVoid          F;
  snt::text::TSequence T(Context);
  vThis = this;

  this->Name(GetClassName())
  | T.New("lineHorzTop") & T.New("=") & Rrgbw.New() & F.New(FColor, vThis) & Return.New()
  ;
}

// TRuleGrfLineHC //////////////////////////////////////////////////////////////
//
TRuleGrfLineHC::TRuleGrfLineHC( snt::text::TContext &Context, svl::TVariant &VColor, svl::TVariant &VWeight )
: TRuleGrfLine(Context,VColor,VWeight)
{ 
  snt::TReturn         Return;
  snt::TFVoid          F;
  snt::text::TSequence T(Context);
  
  this->Name(GetClassName())
  | T.New("lineHorzCenter") & T.New("=") & Rrgbw.New() & F.New(FColor, vThis) & Return.New()
  ;
}

// TRuleGrfLineHB //////////////////////////////////////////////////////////////
//
TRuleGrfLineHB::TRuleGrfLineHB( snt::text::TContext &Context, svl::TVariant &VColor, svl::TVariant &VWeight )
: TRuleGrfLine(Context,VColor,VWeight)
{ 
  snt::TReturn         Return;
  snt::TFVoid          F;
  snt::text::TSequence T(Context);
  
  this->Name(GetClassName())
  | T.New("lineHorzBottom") & T.New("=") & Rrgbw.New() & F.New(FColor, vThis) & Return.New()
  ;
}

// TRuleGrfLineVL //////////////////////////////////////////////////////////////
//
TRuleGrfLineVL::TRuleGrfLineVL( snt::text::TContext &Context, svl::TVariant &VColor, svl::TVariant &VWeight )
: TRuleGrfLine(Context,VColor,VWeight)
{ 
  snt::TReturn         Return;
  snt::TFVoid          F;
  snt::text::TSequence T(Context);
  
  this->Name(GetClassName())
  | T.New("lineVertLeft") & T.New("=") & Rrgbw.New() & F.New(FColor, vThis) & Return.New()
  ;
}

// TRuleGrfLineVC //////////////////////////////////////////////////////////////
//
TRuleGrfLineVC::TRuleGrfLineVC( snt::text::TContext &Context, svl::TVariant &VColor, svl::TVariant &VWeight )
: TRuleGrfLine(Context,VColor,VWeight)
{ 
  snt::TReturn         Return;
  snt::TFVoid          F;
  snt::text::TSequence T(Context);
  
  this->Name(GetClassName())
  | T.New("lineVertCenter") & T.New("=") & Rrgbw.New() & F.New(FColor, vThis) & Return.New()
  ;
}

// TRuleGrfLineVR //////////////////////////////////////////////////////////////
//
TRuleGrfLineVR::TRuleGrfLineVR( snt::text::TContext &Context, svl::TVariant &VColor, svl::TVariant &VWeight )
: TRuleGrfLine(Context,VColor,VWeight)
{ 
  snt::TReturn         Return;
  snt::TFVoid          F;
  snt::text::TSequence T(Context);
  
  this->Name(GetClassName())
  | T.New("lineVertRight") & T.New("=") & Rrgbw.New() & F.New(FColor, vThis) & Return.New()
  ;
}